
docker exec -i mysql bash <<'EOF'
 
mkdir -p /backup/mysql/$(date +%Y%m%d)

# 备份所有数据库
mysqldump --no-defaults --events --all-databases -uroot -p123456 > /backup/mysql/$(date +%Y%m%d)/all_$(date +%Y%m%d_%H%M%S).sql
 
exit
 
EOF
 
mkdir -p ~/docker/mysql/backup/$(date +%Y%m%d)
 
docker cp mysql:/backup/mysql/$(date +%Y%m%d) ~/docker/mysql/backup/
